package leihua.crm.workbench.web.controller;

import leihua.crm.workbench.domain.BarVO;
import leihua.crm.workbench.domain.FunnelVO;
import leihua.crm.workbench.service.TranService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author leiHua
 * @Date 2022/10/27 21:11
 */
@Controller
public class ChartController {
    @Autowired
    TranService tranService;
    @RequestMapping("/workbench/chart/transaction/index.do")
    public String index(){
        //跳转页面
        return "workbench/chart/transaction/index";
    }

    @RequestMapping("/workbench/chart/transaction/queryCountOfTranGroupByStage.do")
    @ResponseBody
    public Object queryCountOfTranGroupByStage(){
        List<FunnelVO> funnelVOList = tranService.queryCountOfTranGroupByStage();
        return funnelVOList;
    }


    @RequestMapping("/workbench/chart/transaction/activity.do")
    public String activity(){
        //跳转页面
        return "workbench/chart/activity/index";
    }

    @RequestMapping("/workbench/chart/transaction/activity/queryCountOfTranGroupByActivity.do")
    @ResponseBody
    public Object queryCountOfTranGroupByActivity(){
        List<BarVO> barVOList = tranService.queryCountOfTranGroupByActivity();
        List<String> nameList=new ArrayList<>();
        List<String> valueList=new ArrayList<>();
        for (BarVO barVO : barVOList) {
            nameList.add(barVO.getName());
            valueList.add(barVO.getValue());
        }
        Map<String,Object> map=new HashMap<>();
        map.put("nameList",nameList);
        map.put("valueList",valueList);
        return map;
    }


}
